package com.briup.cms.web.controller;

import com.briup.cms.bean.Carousel;
import com.briup.cms.service.ICarouselService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(tags = "轮播图接口")
@RestController
@RequestMapping("/auth/carousel")
public class CarouselController {
    @Autowired
    private ICarouselService service;
    @ApiOperation(value = "查询所有")
    @GetMapping("/page/query")
    public Message findAllCarouselByPage(int pageSize, int pageNum) {
        PageInfo<Carousel> pageInfo = service.findAll(pageSize,pageNum);
        return MessageUtil.success(pageInfo);
    }
    @ApiOperation(value = "保存数据")
    @PostMapping("/save")
    public Message saveCarousel(Carousel carousel) {
        service.saveCarousel(carousel);
        return MessageUtil.success("保存成功");
    }
    @ApiOperation(value = "查询启用状态")
    @GetMapping("/find/yes")
    public Message findYesByStatus() {
        List<Carousel> list3=service.findYesByStatus(1);
        return MessageUtil.success(list3);
    }
    @ApiOperation(value = "删除数据")
    @DeleteMapping("/deleteById")
    public Message deleteById(int id) {
        service.deleteById(id);
        return MessageUtil.success("操作成功");
    }
    @ApiOperation(value = "更新数据")
    @PutMapping("/update")
    public Message updateCarousel(Carousel carousel){
        service.updateCarousel(carousel);
        return MessageUtil.success("更新成功");
    }


}
